export default function verticalLinesPlugin({ onChartClick } = {}) {
  function drawLines(u) {
    u.redraw(false)

    const { ctx, bbox } = u

    if (
      !u.verticalLineNeedUpdate ||
      !u.verticalLines ||
      !Array.isArray(u.verticalLines)
    ) {
      return
    }

    u.verticalLines.forEach(xVal => {
      const xPos = u.valToPos(xVal, 'x', true)

      ctx.beginPath()
      ctx.strokeStyle = 'red'
      ctx.lineWidth = 1
      ctx.moveTo(xPos, bbox.top)
      ctx.lineTo(xPos, bbox.top + bbox.height)
      ctx.stroke()
    })
  }

  return {
    hooks: {
      draw: drawLines
    }
  }
}
